# encoding: utf-8


"""

@author: tongzhenguo

@time: 2021/6/16 下午5:02

@desc:


"""
import time

from redis import Redis
from rq import Queue

from schedule.job import fn, fn2, fn3

q = Queue(connection=Redis())
q1 = Queue(name='low', connection=Redis(), at_front=True)
q2 = Queue(name='low', connection=Redis(), is_async=False)

# job1 = q.enqueue(fn)
# job2 = q.enqueue(fn2, depends_on=job1.id)
# # Now, wait a while, until the worker is finished
# time.sleep(2)
# print(job1.result)
# print(job2.result)

# job1 = q2.enqueue(fn)
# job2 = q2.enqueue(fn2)
# print(job1.result)
# print(job2.result)

# job1 = q2.enqueue_call(fn3, args=("111", "222"), timeout=30)
# print(job1.result)
#
job1 = q2.enqueue_call("schedule.job.fn3", args=("111", "222"), timeout=30,job_id="my_fn3")
print(job1.result)

# Getting the number of jobs in the queue
print(len(q))


job = q.fetch_job('my_fn3') # Returns job having ID "my_id"
print()



